<template>
  <div>
    <div class="record_box">
      <div class="title">
        <div>
          <h2><slot></slot></h2>
        </div>
        <div class="more"  @click="tohistory()">
          更多<span>></span>
        </div>
      </div>
      <van-empty v-show="isEmpty" description="暂无数据"></van-empty>
      <div v-show="!isEmpty" class="record_item" v-for="item in history">
        <div class="hitory">
          <div class="hitory-one">
            {{item.base_name}}{{item.house_name}}
            <span class="hsty-t" v-if="item.type==1&&item.scope==1">温度<span>{{item.sources}}℃</span>超出设定的<span>【{{item.scope_min}}℃-{{item.scope_max}}℃】</span>范围</span>
            <span class="hsty-t" v-if="item.type==1&&item.scope==2">温度<span>{{item.sources}}℃</span>低于设定的<span>【{{item.scope_min}}℃-{{item.scope_max}}℃】</span>范围</span>
            <span class="hsty-t" v-if="item.type==2&&item.scope==1">湿度<span>{{item.sources}}%</span>超出设定的<span>【{{item.scope_min}}%-{{item.scope_max}}%】</span>范围</span>
            <span class="hsty-t" v-if="item.type==2&&item.scope==2">湿度<span>{{item.sources}}%</span>低于设定的<span>【{{item.scope_min}}%-{{item.scope_max}}%】</span>范围</span>

            <span class="hsty-f" v-if="item.type==1">{{item.exceed}}℃</span>
            <span class="hsty-f" v-else>{{item.exceed}}%</span>
          </div>
        </div>
        <div class="hitory-date">{{item.create_time}}</div>
      </div>
    </div>
  </div>
</template>

<script>
    export default {
        name: "historyView",
      props: {
        history: {
          type: Array,
          default() {
            return []
          }
        },
        isEmpty:{
          type:true,
          default(){
            return false
          }
        }
      },
      data() {
        return {

        }
      },
      created(){

      },
      methods: {
        tohistory:function (e) {
          this.$router.push({path:'/history', query:{}})
        },
      }
    }
</script>

<style scoped>
  .record_box{
    margin: 10px;
    background: #ffffff;
    border-radius: 8px;
  }
  .record_box .title {
    padding: 10px;
  }
  .record_box .title h2{
    padding-left: 5px;
    font-size: .32rem;
    /*color: var(--color-tint);*/
    border-left: 3px solid var(--color-tint);
    font-weight: normal;
  }
  .record_item{
    padding: 10px;
    font-size: .28rem;
    border-top: 1px solid #eee;
  }
</style>
